"use strict";
//声明函数
//1. 普通函数声明
function add(a, b) {
    return a + b;
}
//2. 函数表达式 『匿名函数赋值』
let minus = function (a, b) {
    return a - b;
};
//3. 箭头函数赋值
let times = (x, y) => {
    return x * y;
};
//函数类型变量的类型声明
let divide;
divide = (x, y) => {
    return x / y;
};
//指数运算 2^3
let pow = (a, b) => {
    return Math.pow(a, b);
};
// console.log(pow(2, 3));
//函数参数  用来截取字符串
function slice(str, start, end) {
    return str.slice(start, end);
}
// console.log(slice('iloveyou', 1, 5));
// console.log(slice('iloveyou', 1));
//参数的默认值
function buildPhone(code, area = '+86') {
    return area + code;
}
console.log(buildPhone('15869584723', '+86'));
console.log(buildPhone('18456235874'));
console.log(buildPhone('25874562232', '+260'));
//计算所有参数的和  rest 参数
function jia(...args) {
    return args.reduce((prev, cur) => prev + cur);
}
console.log(jia(1, 2));
console.log(jia(200, 345, 908));
